﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Bussines
{
    public class clINTEZMENYEK
    {
        public int fINT_ID;
        public int fINT_TIPUS;
        public string fINT_MEGNEVEZES;
        public double fINT_SZAZALEK;

        public clINTEZMENYEK(int iINT_ID, int iINT_TIPUS, string iINT_MEGNEVEZES, double iINT_SZAZALEK)
        {
            fINT_ID = iINT_ID;
            fINT_TIPUS = iINT_TIPUS;
            fINT_MEGNEVEZES = iINT_MEGNEVEZES;
            fINT_SZAZALEK = iINT_SZAZALEK;
        }
    }

    public class clINTEZMENYEK_LIST
    {
        private SqlConnection sc;

        public List<clINTEZMENYEK> lINTEZMENYEK = new List<clINTEZMENYEK>();

        public clINTEZMENYEK_LIST(TBLObj iBLObj,int iTipus)
        {
            /*
                iTipus 
             *      0-minden
             *      1-Bank
             *      2-Biztosító
             *      3-Nyugdij
             */
            TBLObj pBLObj = iBLObj;
            sc = iBLObj.sqlConnection;

            SqlCommand cmd = new SqlCommand();

            cmd.Connection = sc;

            cmd.CommandType = CommandType.Text;

            cmd.CommandText = "SELECT INT_ID, INT_TIPUS, INT_MEGNEVEZES, INT_SZAZALEK " +
                "FROM INTEZMENYEK ";
            switch (iTipus)
            {
                case 0:
                    cmd.CommandText += " ";
                    break;
                default:
                    cmd.CommandText += " WHERE INT_TIPUS = " + iTipus.ToString();
                    break;
            }
            /*
            cmd.Parameters.Add(new SqlParameter("TPS_KATEGORIA", SqlDbType.VarChar));

            cmd.Parameters["TPS_KATEGORIA"].Value = iTPS_KATEGORIA;
            */

            SqlDataReader rdr = cmd.ExecuteReader();
            while (rdr.Read())
            {
                clINTEZMENYEK t = new clINTEZMENYEK((int)rdr["INT_ID"], (int)rdr["INT_TIPUS"], rdr["INT_MEGNEVEZES"].ToString(), Convert.ToDouble(rdr["INT_SZAZALEK"].ToString()));
                lINTEZMENYEK.Add(t);
            }
            rdr.Close();
        }

    }
}
